package dletc.IO;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Copy02 {

	public static void main(String[] args)  {
		// 文件复制用字符流
		
		FileReader fr = null;
		
		FileWriter fw = null;
		
		try {
			fr = new FileReader("A.txt");
			
			fw= new FileWriter("D:\\A.txt");
			
			//复制
			char[] ch = new char[1024];
			int len;
			while((len = fr.read(ch)) != -1){
				fw.write(ch,0,len);
			}
			
			fw.flush();
			
		} catch (FileNotFoundException e) {
			
			e.printStackTrace();
		} catch (IOException e) {
			
			e.printStackTrace();
		} finally {
			
			if(fw != null){
				try {
					fw.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			
			if(fr != null){
				try {
					fr.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
		 
		
		
		

	}

}
